/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package model;

import java.sql.SQLException;
import java.util.ArrayList;
import javax.swing.table.AbstractTableModel;

/**
 *
 * @author SMK N 2 PENGASIH
 */
public class MahasiswaTableModel extends AbstractTableModel {

    String columNames[] = {"Nama", "Nim", "tlpn", "email", "prodi", "periode", "tanggal", "hari"};
    ArrayList data;

    public MahasiswaTableModel(String keyword) throws SQLException {
        Mahasiswa d = new Mahasiswa();
//        data = Mahasiswa.searchMahasiswa(keyword);
    }

    public int getRowCount() {
        return data.size();
    }

    public int getColumnCount() {
        return columNames.length;
    }

    @Override
    public String getColumnName(int col) {
        return columNames[col];
    }

    public Object getValueAt(int rowIndex, int columnIndex) {
        Mahasiswa temp = (Mahasiswa) data.get(rowIndex);
        switch (columnIndex) {
            case 0:
                return temp.getNama();
            case 1:
                return temp.getNim();
            case 2:
                return temp.getEmail();
            case 3:
                return temp.getProdi();
            case 4:
                return temp.getTanggal();
            case 5:
                return temp.getHari();

            case 6:
                return temp.getTlpn();
            case 7:
                return temp.getPeriode();
        }
        return null;
    }

    @Override
    public Class getColumnClass(int c) {
        return getValueAt(0, c).getClass();
    }
}
